/*
 * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Unlicense OR CC0-1.0
 */

#ifndef WS2812_H
#define WS2812_H

#include "led_strip.h"
#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

// Set to 1 to use DMA for driving the LED strip, 0 otherwise
// Please note the RMT DMA feature is only available on chips e.g. ESP32-S3/P4
#define LED_STRIP_USE_DMA  1

#if LED_STRIP_USE_DMA
// Numbers of the LED in the strip
#define LED_STRIP_LED_COUNT 256
#define LED_STRIP_MEMORY_BLOCK_WORDS 1024 // this determines the DMA block size
#else
// Numbers of the LED in the strip
#define LED_STRIP_LED_COUNT 24
#define LED_STRIP_MEMORY_BLOCK_WORDS 0 // let the driver choose a proper memory block size automatically
#endif // LED_STRIP_USE_DMA

// GPIO assignment
#define LED_STRIP_GPIO_PIN  48

// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define LED_STRIP_RMT_RES_HZ  (10 * 1000 * 1000)

// Global LED strip handle
extern led_strip_handle_t led_strip;

/**
 * @brief Configure LED strip with proper settings
 *
 * @return led_strip_handle_t Handle to the configured LED strip
 */
led_strip_handle_t configure_led(void);

/**
 * @brief Initialize WS2812 LED strip
 *
 * This function initializes the WS2812 LED strip by calling configure_led()
 */
void ws2812_init(void);

#ifdef __cplusplus
}
#endif

#endif // WS2812_H
